﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ForexTester
{
    public class Deal
    {
        private int f_Quantity = 0;
        public int Quantity
        {
            get
            {
                return f_Quantity;
            }
            set
            {
                f_Quantity = value;
                f_TotalProfit = f_ItemProfit * f_Quantity;
                f_ActualProfit = f_TotalProfit - (f_Spread * f_Quantity);
            }
        }

        private decimal f_Spread = 0;
        public decimal Spread
        {
            get { return f_Spread; }
            set
            {
                f_Spread = value;
                f_ActualProfit = f_TotalProfit - (f_Spread * f_Quantity);
            }
        }

        private DealType f_DealType = DealType.Buy;
        public DealType DealType
        {
            get { return f_DealType; }
            set
            {
                f_DealType = value;
                f_ItemProfit = (f_DealType == DealType.Buy ? 1 : -1) * (f_EndPrice - f_StartPrice);
                f_TotalProfit = f_ItemProfit * f_Quantity;
                f_ActualProfit = f_TotalProfit - (f_Spread * f_Quantity);
                f_ProfitPoints = (int)(ItemProfit * 100);
                f_IsLoss = ItemProfit < 0;
            }
        }

        private DealState f_State = DealState.Unopened;
        public DealState State
        {
            get { return f_State; }
            set { f_State = value; }
        }


        private DateTime f_StartDate = DateTime.Now;
        public DateTime StartDate
        {
            get { return f_StartDate; }
            set { f_StartDate = value; }
        }

        private decimal f_StartPrice = 0;
        public decimal StartPrice
        {
            get { return f_StartPrice; }
            set
            {
                f_StartPrice = value;
                f_ItemProfit = (f_DealType == DealType.Buy ? 1 : -1) * (f_EndPrice - f_StartPrice);
                f_TotalProfit = f_ItemProfit * f_Quantity;
                f_ActualProfit = f_TotalProfit - (f_Spread * f_Quantity);
                f_ProfitPoints = (int)(ItemProfit * 100);
                f_IsLoss = ItemProfit < 0;
            }
        }

        private DateTime f_EndDate = DateTime.Now;
        public DateTime EndDate
        {
            get { return f_EndDate; }
            set { f_EndDate = value; }
        }

        private decimal f_EndPrice;
        public decimal EndPrice
        {
            get { return f_EndPrice; }
            set
            {
                f_EndPrice = value;
                f_ItemProfit = (f_DealType == DealType.Buy ? 1 : -1) * (f_EndPrice - f_StartPrice);
                f_TotalProfit = f_ItemProfit * f_Quantity;
                f_ActualProfit = f_TotalProfit - (f_Spread * f_Quantity);
                f_ProfitPoints = (int)(ItemProfit * 100);
                f_IsLoss = ItemProfit < 0;
            }
        }




        private decimal f_ItemProfit =0;
        public decimal ItemProfit
        {
            get
            {
                return f_ItemProfit;
            }
        }
        
        private decimal f_TotalProfit =0;
        public decimal TotalProfit
        {
            get
            {
                return f_TotalProfit;
            }
        }

        private decimal f_ActualProfit =0;
        public decimal ActualProfit
        {
            get
            {
                return f_ActualProfit;
            }
        }

        private int f_ProfitPoints =0;
        public int ProfitPoints
        {
            get
            {
                return f_ProfitPoints;
            }
        }

        private bool f_IsLoss =false;
        public bool IsLoss
        {
            get { return f_IsLoss; }
        }




        private int f_StopLoss = 0;
        public int StopLoss
        {
            get { return f_StopLoss; }
            set { f_StopLoss = value; }
        }

        private int f_TrailingStop = 0;
        public int TrailingStop
        {
            get { return f_TrailingStop; }
            set { f_TrailingStop = value; }
        }

        private int f_TakeProfit = 0;
        public int TakeProfit
        {
            get { return f_TakeProfit; }
            set { f_TakeProfit = value; }
        }

        private decimal f_PrevouisTrailing = -1;
        public decimal PrevouisTrailing
        {
            get { return f_PrevouisTrailing; }
            set { f_PrevouisTrailing = value; }
        }


    }
}